import * as types from './mutation-types'

export const getToken = (state, token) => {
  state.token = token
  sessionStorage.token = token
}

export const getUserid = (state, userid) => {
  state.userid = userid
  state.userId = userid
  sessionStorage.userid = userid
}

export const getUserInfo = (state, userinfo) => {
  state.userinfo = JSON.stringify(userinfo)
  state.roleid = userinfo.role.role_id
  sessionStorage.userinfo = JSON.stringify(userinfo)
  sessionStorage.roleid = userinfo.role.role_id
}

export const getExpertinfo = (state, expertinfo) => {
  state.expertinfo = expertinfo
  sessionStorage.expertinfo = expertinfo
}

export const SignIn = state => {
  state.isLogin = true
  sessionStorage.isLogin = true
}

export const SignOut = state => {
  state.token = ''
  state.userid = ''
  state.userinfo = {}
  sessionStorage.clear()
}
